{% load bootstrap3 %}
{% load blog_tags %}
{% load staticfiles %}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>孤月汐鸿---成长之路</title>
  {% bootstrap_css %}
  {% bootstrap_javascript %}
  <link href="{% static "css/blog.css" %}" rel="stylesheet">
</head>
<body>
<!-- Static navbar -->
<nav class="navbar navbar-default navbar-fixed-top">
  <div class="container">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
        </button>
        <a class="navbar-brand" href="{% url 'blog:index' %}">我的博客</a>
    </div>
    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li  class="active"><a href="{% url 'blog:post_list' %}">全部博文</a></li>
        {% for category in categories %}
          <li><a href="#">{{ category }}</a></li>
        {% endfor %}
      </ul>
      <ul class="nav navbar-nav navbar-right">
          <li class="dropdown">
              {% if user.is_authenticated %}
              <a data-target="#" href="{% url 'blog:index' %}" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
              {% if user.first_name %}
              欢迎，{{ user.first_name }}
              {% else %}
              欢迎，{{ user.username }}
              {% endif %}
              <span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="{% url 'blog:post_add' %}">写文章</a></li>
                <li><a href="/admin">管理站点</a></li>
                <li><a href="{% url 'users:logout' %}">注销</a></li>
              {% else %}
              <a data-target="#" href="{% url 'blog:index' %}" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">用户未登录
              <span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="{% url 'users:register' %}">注册</a></li>
                <li><a href="{% url 'users:login' %}">登陆</a></li>
              {% endif %}
              </ul>
          </li>
      </ul>
    </div><!--/.nav-collapse -->
  </div>
</nav>
<div class="container">
  <div class="page-header">
    {% block header %}{% endblock header %}
  </div>
  <div id="sidebar">
    <h3>最新的文章</h3>
      {% show_latest_posts 3 %}
    <h3>评论最多的文章</h3>
      {% get_most_commented_posts as most_commented_posts %}
      <ul>
        {% for post in most_commented_posts %}
        <li>
          <a href="{{ post.get_absolute_url }}">{{ post.title }}</a>
        </li>
        {% endfor %}
      </ul>
  </div>
  <div id="content">
    {% block content %}{% endblock content %}
  </div>
</div>
</body>
</html>
